<template>
  <div class="content">
    <van-nav-bar title="首页" />
    <div class="top-content">
      <div class="user-info">
        <div class="avatar-content">
          <van-image
            round
            width="50px"
            height="50px"
            src="https://img01.yzcdn.cn/vant/cat.jpeg"
          />
        </div>
        <div class="right-content">
          <div class="name-content">
            {{ getUserInfo().nickName || "夏琳恒" }}
            <span class="post">心内科·主任医师</span>
          </div>
          <div class="info-content">浙江省人民医院（天府院区）</div>
        </div>
      </div>
    </div>

    <div class="kuai-jie-content">
      <van-grid :border="false" icon-size="64px">
        <van-grid-item
          :icon="require('@/assets/home/img1.png')"
          text="上报"
          @click="goto(1)"
        />
        <van-grid-item
          :icon="require('@/assets/home/img2.png')"
          text="我的上报"
          @click="goto(2)"
        />
        <van-grid-item
          :icon="require('@/assets/home/img3.png')"
          text="上报审批"
          @click="goto(3)"
        />
        <van-grid-item
          :icon="require('@/assets/home/img4.png')"
          text="分析审批"
          @click="goto(4)"
        />
      </van-grid>
    </div>
    <div class="schedule-content">
      <div class="title-content">待办事项</div>
      <div class="list-content">
        <div
          class="list-item"
          v-for="(item, index) in listData"
          :key="item.id"
          @click="toCheck(item)"
        >
          <div class="item-content">
            <div class="left-content">
              <van-tag round size="large" type="warning">待审批</van-tag>
            </div>
            <div class="right-content">
              <div>
                <div class="title">
                  {{ item.title }}
                </div>
                <div class="item-date">
                  {{ moment(item.create_time).format("MM月DD日 HH:mm") }}
                </div>
              </div>
            </div>
          </div>
          <div class="bottom-btn">
            <van-button type="info" round size="small" style="width: 60px">
              审 批
            </van-button>
          </div>
        </div>
      </div>
    </div>
    <div class="message-content">
      <div class="title-content">
        <div>消息通知</div>
        <div class="more-btn" @click="moreMsg">
          更多消息<van-icon name="arrow" color="#bbb" size="18" />
        </div>
      </div>
      <div class="list-content">
        <div
          class="list-item"
          v-for="(item, index) in listData"
          :key="item.id"
          @click="toCheck(item)"
        >
          <div class="item-content">
            <div class="left-content">
              <van-icon name="chat-o" color="#bbb" size="24" />
            </div>
            <div class="right-content">
              <div>
                <div class="title">
                  {{ item.title }}
                </div>
              </div>
            </div>
          </div>
          <div class="item-date">
            {{ moment(item.create_time).format("MM-DD") }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import { asyncBanner, asyncCan } from "@/api/home";
import moment from "moment";

export default {
  data() {
    return {
      listData: [
        {
          title: "手术事件上报待审批",
          info: "",
          date: "2024-3-18 11:00:00",
        },
        {
          title: "手术事件上报待审批",
          info: "",
          date: "2024-3-18 11:00:00",
        },
        {
          title: "手术事件上报待审批",
          info: "",
          date: "2024-3-18 11:00:00",
        },
        {
          title: "手术事件上报待审批",
          info: "",
          date: "2024-3-18 11:00:00",
        },
        {
          title: "手术事件上报待审批",
          info: "",
          date: "2024-3-18 11:00:00",
        },
      ],
    };
  },
  methods: {
    moment,
    getUserInfo() {
      const info = Vue.ls.get("userInfo") || {};
      const userInfo = info.user || {};
      return userInfo;
    },
    goto(flag) {
      if (flag === 1) {
        this.$router.push({
          path: "/report",
        });
      } else if (flag === 2) {
        uni.navigateTo({
          url: "/pages/home/components/reportList",
        });
      } else if (flag === 3) {
        uni.navigateTo({
          url: "/pages/home/components/approvalList",
        });
      } else {
        uni.navigateTo({
          url: "/pages/home/components/analyseList",
        });
      }
    },
    //去查看
    toCheck(data) {
      this.$router.push({
        path: `/message/detail?id=${data.id}`,
      });
    },
    //更多消息
    moreMsg() {
      this.$router.push({
        path: "/message",
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.content {
  padding-bottom: 64px;

  .top-content {
    height: 300px;
    background-image: url("~@/assets/login/login-bg.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding: 24px;

    .user-info {
      display: flex;
      align-items: center;
      background-color: #fff;
      border-radius: 8px;
      padding: 12px;

      .right-content {
        margin-left: 24px;
        font-size: 16px;

        .name-content {
          font-weight: 600;

          .post {
            margin-left: 12px;
            color: #333;
            font-size: 14px;
            font-weight: 500;
          }
        }

        .info-content {
          margin-top: 12px;
          font-size: 14px;
        }
      }
    }
  }
  ::v-deep .van-grid-item__content {
    background-color: transparent !important;
  }
  .kuai-jie-content {
    margin: 0 24px;
    margin-top: -240px;
    font-size: 14px;
    color: #3d3d3d;
  }

  .schedule-content,
  .message-content {
    padding: 12px;
    background-color: #fff;
    margin: 0 12px;
    border-radius: 8px;

    .title-content {
      font-size: 15px;
      font-weight: 600;
      margin-bottom: 24px;
    }

    .list-content {
      .list-item {
        margin: 12px 0;
        border-bottom: 1px solid #e8e8e8;
        padding: 12px;
        display: flex;
        justify-content: space-between;

        .item-content {
          display: flex;

          .right-content {
            margin-left: 12px;

            .title {
              font-size: 14px;
              font-color: #101010;
            }

            .item-date {
              margin-top: 12px;
              font-size: 14px;
              color: #bbb;
            }
          }
        }

        .bottom-btn {
          margin-left: 24px;
        }
      }

      .list-item:last-child {
        border-bottom: none;
      }
    }
  }

  .message-content {
    margin-top: 12px;
    .title-content {
      display: flex;
      justify-content: space-between;

      .more-btn {
        display: flex;
        font-size: 15px;
        font-weight: 500;
        color: #bbb;
      }
    }

    .item-date {
      color: #bbb;
    }
  }
}
</style>
